<%@page import="javax.imageio.ImageIO"%>
<%@page import="java.io.*"%>
<%@page import="java.awt.Graphics2D"%>
<%@page import="java.awt.image.BufferedImage"%>
<%@page import="javax.media.jai.JAI"%>
<%@page import="javax.media.jai.RenderedOp"%>
<%@page import="java.awt.image.renderable.ParameterBlock"%>
<%@page import="com.sun.org.apache.xalan.internal.xsltc.runtime.Parameter"%>
<%@page import="java.util.*"%>
<%@page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy"%>
<%@page import="com.oreilly.servlet.MultipartRequest"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
    
    
    <%
   		String imagePath=request.getRealPath("/Image");
    
    	int size=1*1024*1024;
    	String filename="";
    	
    	try{
    		MultipartRequest multi= new MultipartRequest(request,
    													imagePath,
    													size,
    													"euc-kr",
    													new DefaultFileRenamePolicy());
    		Enumeration files=multi.getFileNames();
    		
    		String file=(String)files.nextElement();
    	filename=multi.getFilesystemName(file);    	
    	}catch(Exception e){
    		e.printStackTrace();
    	}    
    	ParameterBlock pb = new ParameterBlock();
    	pb.add(imagePath+"/"+filename);
    	RenderedOp rOp=JAI.create("fileload",pb);
    	
    	BufferedImage bi= rOp.getAsBufferedImage();
    	BufferedImage thumb= new BufferedImage(100,100,BufferedImage.TYPE_INT_RGB);
    	
    	Graphics2D g=thumb.createGraphics();
    	g.drawImage(bi,0,0,100,100,null);
    	
    	File file = new File(imagePath+"/sm_"+filename);
    	ImageIO.write(thumb, "jpg", file);
    %>
    <%=imagePath %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title> Image sum nail ex </title>
</head>
<body>
- Image 1 <br>
<img src="../Image/<%=filename %>"><p>
- Image 2 <br>
<img src="../Image/sm_<%=filename %>">
</body>
</html>